home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / Mark Pilgrim / Dialectic 1.2 / source / Dialectic ƒ / Shell ƒ / about MSG.c next >
Encoding:
C/C++ Source or Header  |  1994-10-30  |  5.8 KB  |  223 lines  |  [TEXT/KAHL]

  1. /**********************************************************************\
  2.  
  3. File:        about MSG.c
  4.  
  5. Purpose:    This module handles displaying the "About MSG" splash
  6.             screen.
  7.  
  8. \**********************************************************************/
  9.  
  10. #include "graphics.h"        /* needs to come first because it defines WindowDataHandle */
  11. #include "about MSG.h"
  12. #include "environment.h"
  13.  
  14. extern Point RawMouse : 0x82C;
  15.  
  16. /*-----------------------------------------------------------------------------------*/
  17. /* internal stuff for about MSG.c                                                    */
  18.  
  19. void SetupTheAboutMSGWindow(WindowDataHandle theData);
  20. void DrawTheAboutMSGWindow(void);
  21. void DoTheMSGThing(WindowDataHandle theData);
  22. void ActivateTheMSGWindow(void);
  23. void DeactivateTheMSGWindow(WindowDataHandle theData);
  24. void GetTheNextLine(Handle textHandle, unsigned long theSize, unsigned long *pos, Str255 theLine);
  25. void DrawTheAboutString(Str255 theString, int theWidth, int *theRow);
  26. void DrawTheCarpet(void);
  27. void DrawTheString(Str255 theString, int theWidth, int* theRow);
  28. void DrawCarpet(int x, int y, int len);
  29.  
  30. static int        gOldForegroundTime;
  31.  
  32. int AboutMSGBoxDispatch(ExtendedWindowDataHandle theData, int theMessage, unsigned long misc)
  33. {
  34.     int                theDepth;
  35.     
  36.     switch (theMessage)    /* see graphics.h for list of messages*/
  37.     {
  38.         case kNull:
  39.             DoTheMSGThing(theData);
  40.             return kSuccess;
  41.             break;
  42.         case kUpdate:
  43.             DrawTheAboutMSGWindow();
  44.             return kSuccess;
  45.             break;
  46.         case kActivate:
  47.             ActivateTheMSGWindow();
  48.             return kSuccess;
  49.             break;
  50.         case kDeactivate:
  51.             DeactivateTheMSGWindow(theData);
  52.             return kSuccess;
  53.             break;
  54.         case kKeydown:                            /* close about box on keypress */
  55.         case kMousedown:                        /* or mouseclick */
  56.             CloseTheWindow(theData);
  57.             return kSuccess;
  58.             break;
  59.         case kStartup:
  60.             SetupTheAboutMSGWindow(theData);
  61.             return kSuccess;
  62.             break;
  63.     }
  64.     
  65.     return kFailure;        /* for all other messages, defer to default processing */
  66. }
  67.  
  68. void SetupTheAboutMSGWindow(WindowDataHandle theData)
  69. {
  70.     (**theData).windowWidth=243;
  71.     (**theData).windowHeight=243;
  72.     (**theData).windowType=plainDBox;        /* plain rectangle */
  73.     (**theData).windowTitle[0]=0x00;        /* null title, never shown */
  74.     (**theData).hasCloseBox=FALSE;
  75. }
  76.  
  77. void ActivateTheMSGWindow(void)
  78. {
  79.     gOldForegroundTime=gForegroundWaitTime;
  80.     gForegroundWaitTime=0;
  81. }
  82.  
  83. void DeactivateTheMSGWindow(WindowDataHandle theData)
  84. {
  85.     UpdateTheWindow(theData);
  86.     gForegroundWaitTime=gOldForegroundTime;
  87. }
  88.  
  89. void DoTheMSGThing(WindowDataHandle theData)
  90. {
  91.     Rect            sourceRect, destRect;
  92.     Rect            mainRect;
  93.     long            lr,tb;
  94.     int                l,t;
  95.     int                index;
  96.     
  97.     index=(**theData).windowIndex;
  98.     mainRect=screenBits.bounds;
  99.     if (PtInRect(RawMouse, &mainRect))
  100.     {
  101.         lr=RawMouse.h-mainRect.left;
  102.         lr*=81;
  103.         lr/=mainRect.right-mainRect.left;
  104.         tb=RawMouse.v-mainRect.top;
  105.         tb*=81;
  106.         tb/=mainRect.bottom-mainRect.top;
  107.         if (tb<0)
  108.             tb=0;
  109.         l=RawMouse.h-lr;
  110.         t=RawMouse.v-tb;
  111.         SetRect(&sourceRect, l, t, l+81, t+81);
  112.         SetRect(&destRect, 81, 81, 162, 162);
  113.         SetPort(gTheWindow[index]);
  114.         CopyBits(&(WMgrPort->portBits), &(gTheWindow[index]->portBits),
  115.             &sourceRect, &destRect, 0, 0L);
  116.     }
  117. }
  118.  
  119. void DrawTheAboutMSGWindow(void)
  120. {
  121.     int                row;
  122.     Rect            sourceRect, destRect;
  123.     GrafPtr            curPort;
  124.     int                theWidth;
  125.     
  126.     GetPort(&curPort);
  127.     EraseRect(&(curPort->portRect));
  128.     theWidth=curPort->portRect.right-curPort->portRect.left;
  129.     
  130.     DrawCarpet(9,234,3);
  131.     SetRect(&sourceRect, 0, 216, 27, 243);
  132.     destRect=sourceRect;
  133.     OffsetRect(&destRect, 27, 0);
  134.     CopyBits(&(curPort->portBits), &(curPort->portBits),
  135.         &sourceRect, &destRect, 0, 0L);
  136.     OffsetRect(&destRect, -27, -27);
  137.     CopyBits(&(curPort->portBits), &(curPort->portBits),
  138.         &sourceRect, &destRect, 0, 0L);
  139.     OffsetRect(&destRect, 0, -27);
  140.     CopyBits(&(curPort->portBits), &(curPort->portBits),
  141.         &sourceRect, &destRect, 0, 0L);
  142.     OffsetRect(&destRect, 27, 0);
  143.     CopyBits(&(curPort->portBits), &(curPort->portBits),
  144.         &sourceRect, &destRect, 0, 0L);
  145.     SetRect(&sourceRect, 0, 162, 27, 243);
  146.     destRect=sourceRect;
  147.     OffsetRect(&destRect, 54, 0);
  148.     CopyBits(&(curPort->portBits), &(curPort->portBits),
  149.         &sourceRect, &destRect, 0, 0L);
  150.     SetRect(&sourceRect, 0, 162, 81, 243);
  151.     destRect=sourceRect;
  152.     OffsetRect(&destRect, 81, 0);
  153.     CopyBits(&(curPort->portBits), &(curPort->portBits),
  154.         &sourceRect, &destRect, 0, 0L);
  155.     OffsetRect(&destRect, -81, -81);
  156.     CopyBits(&(curPort->portBits), &(curPort->portBits),
  157.         &sourceRect, &destRect, 0, 0L);
  158.     OffsetRect(&destRect, 0, -81);
  159.     CopyBits(&(curPort->portBits), &(curPort->portBits),
  160.         &sourceRect, &destRect, 0, 0L);
  161.     OffsetRect(&destRect, 81, 0);
  162.     CopyBits(&(curPort->portBits), &(curPort->portBits),
  163.         &sourceRect, &destRect, 0, 0L);
  164.     SetRect(&sourceRect, 0, 0, 81, 243);
  165.     destRect=sourceRect;
  166.     OffsetRect(&destRect, 162, 0);
  167.     CopyBits(&(curPort->portBits), &(curPort->portBits),
  168.         &sourceRect, &destRect, 0, 0L);
  169.     
  170.     TextFont(geneva);
  171.     TextSize(9);
  172.     TextMode(srcXor);
  173.     row=92;
  174.     DrawTheString("\pMerriMac", theWidth, &row);
  175.     DrawTheString("\pSoftware", theWidth, &row);
  176.     DrawTheString("\pGroup ’94", theWidth, &row);
  177.     DrawTheString("\p", theWidth, &row);
  178.     DrawTheString("\pStill enhancing", theWidth, &row);
  179.     DrawTheString("\pthe flavor of", theWidth, &row);
  180.     DrawTheString("\pyour Macintosh.", theWidth, &row);
  181. }
  182.  
  183. void DrawTheString(Str255 theString, int theWidth, int* theRow)
  184. {
  185.     MoveTo((theWidth-StringWidth(theString))/2, *theRow);
  186.     DrawString(theString);
  187.     *theRow+=11;
  188. }
  189.  
  190. void DrawCarpet(int x, int y, int len)
  191. {
  192.     Rect            box;
  193.     int                iter;
  194.  
  195.     x-=len*2;
  196.     y+=len*2;
  197.     for (iter=0; iter<8; iter++)
  198.     {
  199.         box.left=x-len;
  200.         box.right=x+2*len;
  201.         box.top=y-2*len;
  202.         box.bottom=y+len;
  203.         FillRect(&box, black);
  204.         if (len>1) DrawCarpet(x,y,len/3);
  205.         box.left=x;
  206.         box.right=x+len;
  207.         box.bottom=y;
  208.         box.top=y-len;
  209.         FillRect(&box, white);
  210.         switch (iter)
  211.         {
  212.             case 0:
  213.             case 1: x+=len*3; break;
  214.             case 2:
  215.             case 3: y-=len*3; break;
  216.             case 4:
  217.             case 5: x-=len*3; break;
  218.             case 6:
  219.             case 7: y+=len*3; break;
  220.         }
  221.     }
  222. }
  223.